﻿@model ProjectBase.Core.ICoreModel

@*
The result of this view is always appended to the page as a JavaScript source file.
(with one of the default MasterPages inherited from MasterBase.cs)
The name contains the specific cultureName:
/Layout/CultureSettings/en-GB
which allows the browser to 1) download it only once and
2) use its content in any JS function.
*@
@{
    var culture = System.Globalization.CultureInfo.CurrentCulture;
    var name = ViewData["cultureName"] as string;
    if (name.IsNotEmpty())
    {
        culture = System.Globalization.CultureInfo
                    .GetCultures(System.Globalization.CultureTypes.AllCultures)
                    .FirstOrDefault(c => c.Name.Equals(name))
                ?? culture;
    }
}

@** Culture name **@
defaultCulture = "@( culture.Name )";

@** DateTime **@
defaultDateTimeFormat = "@( culture.DateTimeFormat
                                .ShortDatePattern
                                .ToLowerInvariant()
                                .Replace("yy", "y")  )";
@** Numbers **@
defaultThousandSeprator = "@X(culture.NumberFormat.NumberGroupSeparator)";
defaultDecimalSeprator = "@X(culture.NumberFormat.NumberDecimalSeparator)";

@** Validator messages localization **@
jQuery.extend(jQuery.validator.messages, {
  required: "@("Required".GetLocalized("ValidationMessages"))",
  max: jQuery.validator.format("@("MaxValue {0}".GetLocalized("ValidationMessages"))"),
  min: jQuery.validator.format("@("MinValue {0}".GetLocalized("ValidationMessages"))"),
    maxlength: jQuery.validator.format("@("MaxLength {0}".GetLocalized("ValidationMessages"))"),
  minlength: jQuery.validator.format("@("MinLength {0}".GetLocalized("ValidationMessages"))")

  @** NOT Used for a default Validator implementation.
    // TODO - append localization for any other phrase to be used on a project

  remote: "Please fix this field.",
  email: "Please enter a valid email address.",
  url: "Please enter a valid URL.",
  date: "Please enter a valid date.",
  dateISO: "Please enter a valid date (ISO).",
  number: "Please enter a valid number.",
  digits: "Please enter only digits.",
  creditcard: "Please enter a valid credit card number.",
  equalTo: "Please enter the same value again.",
  accept: "Please enter a value with a valid extension.",
  rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."),
  range: $.validator.format("Please enter a value between {0} and {1}."),

    // NOTE last statement MIGHT NOT end with "," !!!
    **@
});

doRemove = "@X(GetLocalized(Str.WebControls.Common.DoRemove))"

@if (!Global.Settings.EnableSessionKeeper) { return; }
var KeepSessionOpenAction = "@Url.Action(Str.Business.Home.Actions.KeepSessionOpen,Str.Controllers.Layout)";
SessionTimerID = setTimeout("KeepSessionOpen()", 60000); // ,280000);